#include "SemanticNodeBlockSeize.h"

/**
 *  @fn	SemanticNodeBlockSeize::SemanticNodeBlockSeize(const SyntaxTreeNode *seizeNodeParent,
 *  	SemanticNode *parent)
 * 
 *  @brief	Constructor. 
 * 
 *  @author	Nikola Novak
 *  @date	6/25/2009
 * 
 *  @param	seizeNodeParent	If non-null, the seize node parent.
 *  @param	parent			If non-null, the parent.
 */
SemanticNodeBlockSeize::SemanticNodeBlockSeize(const SyntaxTreeNode *seizeNodeParent, SemanticNode *parent) : SemanticNode(parent), LabeledNode(seizeNodeParent->Nodes->GetData(0)) {
	queue = (seizeNodeParent->Nodes->GetData(1)->Nodes->GetData(0)->Nodes->GetData(2)->Nodes->GetCount() > 0);
}
/**
 *  @fn	bool SemanticNodeBlockSeize::hasQueue(void)
 * 
 *  @brief	Query if this object has queue. 
 * 
 *  @author	Nikola Novak
 *  @date	6/25/2009
 * 
 *  @return	true if queue, false if not.
 */
bool SemanticNodeBlockSeize::hasQueue(void) {
	return queue;
}
/**
 *  @fn	void SemanticNodeBlockSeize::setFacility(SemanticNodeExpression *facility)
 * 
 *  @brief	Sets a facility. 
 * 
 *  @author	Nikola Novak
 *  @date	6/25/2009
 * 
 *  @param	facility	If non-null, the facility.
 */
void SemanticNodeBlockSeize::setFacility(SemanticNodeExpression *facility) {
	facilityExpression = facility;
}
/**
 *  @fn	void SemanticNodeBlockSeize::setQueue(SemanticNodeExpression *seizeQueue)
 * 
 *  @brief	Sets a queue. 
 * 
 *  @author	Nikola Novak
 *  @date	6/25/2009
 * 
 *  @param	seizeQueue	If non-null, queue of seizes.
 */
void SemanticNodeBlockSeize::setQueue(SemanticNodeExpression *seizeQueue) {
	queueExpression = seizeQueue;
}
/**
 *  @fn	std::string SemanticNodeBlockSeize::toDebugString(int tab)
 * 
 *  @brief	Converts a tab to a debug string. 
 * 
 *  @author	Nikola Novak
 *  @date	6/25/2009
 * 
 *  @param	tab	The tab.
 * 
 *  @return	This object as a std::string.
 */
std::string SemanticNodeBlockSeize::toDebugString(int tab) {
	std::ostringstream res;
	for (int i = 0; i < tab; i++)	res << DEBUG_STRING_RAZMAK;
	res << getLabelsDebugString() << ": seize " << std::endl;
	res << ((SemanticNode *)facilityExpression)->toDebugString(tab + 1);
	for (int i = 0; i < tab; i++)	res << DEBUG_STRING_RAZMAK;
	if (!queue) res << "forming implicit Queue" << std::endl;
	else {
		res << "forming" << std::endl << ((SemanticNode *)queueExpression)->toDebugString(tab + 1);
	}
	return res.str();
}
